<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>心情随笔</title>
  <meta name="keywords" content="个人博客模板,博客模板,响应式"/>
  <meta name="description" content="个人博客模板"/>
<link href="css/base.css" rel="stylesheet">
  <link href="css/index.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
<!--[if lt IE 9]>
<script src="js/modernizr.js"></script>
<![endif]-->
</head>
<body>
<div class="ibody">
  <?php include "header.php"; ?>
  <article>
    <h2 class="about_h">您现在的位置是：<a href="index.php">首页</a>&gt;<a href="#">文章列表</a></h2>
    <div class="bloglist whitebg">
      <?
      require_once "./admin/config.php";
      $page = isset($_GET['page'])?$_GET['page']:1;
      $length = 7;
      $offset = ($page-1)*$length+1;
      if(isset($_GET['id'])){
        $id = $_GET['id'];
        $sql = "select * from article where cateid = $id order by id desc limit $offset,$length";
        $totalsql = "select * from article where cateid = $id";
      }else{
        $sql = "select * from article order by id desc limit $offset,$length";
        $totalsql = "select * from article";
      }
      $rst = mysqli_query($con,$sql);
      $totalNums = mysqli_num_rows(mysqli_query($con,$totalsql));
      $totalPage = ceil($totalNums/$length);
      if($page <= 1){
        $page = 1;
      }
      if($page >= $totalPage ){
          $page = $totalPage;
      }
      while($row = mysqli_fetch_assoc($rst)){
      $sql1 = "select * from category where id = {$row['cateid']}";
      $rst1 = mysqli_query($con,$sql1);
      $row1 = mysqli_fetch_assoc($rst1);
        ?>

      <div class="blogs">
        <h3><a href="/"><?php echo $row['title']; ?></a></h3>
        <figure><img src="images/01.jpg"></figure>
        <ul>
          <p><?php echo substr($row['content'],0,552); ?></p>
          <a href="detail.php?id=<?php echo $row['id']; ?>"  class="readmore">阅读全文&gt;&gt;</a>
        </ul>
        <p class="autor"><span>作者：<?php echo $row['author']; ?></span><span>发表：<?php echo date("Y-m-d H:i:s",$row['time']); ?></span><span>分类：【<a href="list.php?id=<?php echo $row1['id']; ?>"><?php echo $row1['cate_name']; ?></a>】</span><span>浏览（<a href="#"><?php echo$row['article_view'];?></a>）</span><span>评论（<a href="#">30</a>）</span></p>
      </div>
      <?php
        }
      ?>

<div align="center">
      <a href="list.php?page=<?php echo $page-1;?>">上一页</a>
  <?php
      for($i=1;$i<=$totalPage;$i++){
          if($i == $page){
          echo "<b>{$i}</b>&nbsp&nbsp";
          continue;
      }
      echo "<a href='list.php?page={$i}'>{$i}</a>&nbsp&nbsp";

  }
  ?>
      <a href="list.php?page=<?php echo $page+1;?>">下一页</a>
  </div>
  </article>

  <aside>
    <div class="whitebg">
      <div class="avatar"><a href="about.php"><span>关于蓝鸥</span></a></div>

      <div class="topspaceinfo">
        <h1>执子之手，与子偕老</h1>
        <p>于千万人之中，我遇见了我所遇见的人....</p>
      </div>
    </div>
    <div class="whitebg">
      <div class="about_c">
        <p>网名：blue gull | 蓝鸥</p>
        <p>职业：php开发工程师 </p>
        <p>籍贯：河南省―郑州市</p>
        <p>电话：15512345678</p>
        <p>邮箱：15512345678@qq.com</p>
      </div>
    </div>
    <div class="whitebg">


      <div class="bdsharebuttonbox"><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_more" data-cmd="more"></a></div>
    </div>
    <?php include "new_article_title_list.php"; ?>
    <div class="whitebg">
      <div class="links">
        <h2>
          <p>友情链接</p>
        </h2>
        <ul>
          <li><a href="index.php">蓝鸥个人博客</a></li>
        </ul>
      </div>
    </div>
    <div class="whitebg">
      <div class="links">
        <h2>
          <p>版权声明</p>
        </h2>
        <ul>
          <li><a href="index.php">powby 蓝鸥</a></li>
          <li><a href="index.php">豫ICP备1234567号</a></li>
        </ul>
      </div>
    </div>
  </aside>
  <script src="js/silder.js"></script>
  <div class="clear"></div>
  <!-- 清除浮动 --> 
</div>
</body>
</html>
